﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel.DataAnnotations;

namespace A2DFramework.ValidationService.RuleValidators
{
    public class RuleStringLengthAttribute:RuleValidationAttribute
    {
        private StringLengthAttribute checker;

        public RuleStringLengthAttribute(int maximumLength):this(string.Empty, maximumLength)
        {
        }
        public RuleStringLengthAttribute(string rule, int maximumLength):base(rule)
        {
            checker = new StringLengthAttribute(maximumLength);
        }

        protected override ValidationResult IsValid(object value, ValidationContext validationContext)
        {
            return checker.GetValidationResult(value, validationContext);
        }
    }
}
